package com.minivision.fdiot.common;

import org.hashids.Hashids;

/**
 * 基于时间戳生成32位的唯一字符串型Code
 * @author hughzhao
 * @2018年1月17日
 */
public final class TimeBasedCode {
  
  private static Hashids hashids = new Hashids("com.minivision.fdiot", 32);
  
  public static String encode(long... args) {
    return hashids.encode(args);
  }
  
  public static long[] decode(String hashid) {
    return hashids.decode(hashid);
  }
  
  public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
      System.out.println(encode(System.nanoTime()));
    }
  }

}
